const mongoose = require('mongoose')

 mongoose.connect('mongodb://root:root@localhost/test', {
    useNewUrlParser: true,
    useUnifiedTopology: true}).then(() =>  console.log('数据库连接成功'))
    .catch(err => console.log(err));

//连接成功
let db = mongoose.connection

db.on('err', () => {
    console.log("连接失败");
})


db.on('open', ()=> {
    console.log('连接成功');
})

